home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Acere (PowerPlant, Game) 1.2 / AcereÄ.sit / Acereƒ / Code / WellFreeCell.cp < prev    next >
Text File  |  1995-02-15  |  5KB  |  179 lines

  1. // ===========================================================================
  2. //    WellFreeCell.cp                        ⌐1993 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    Class for an object that can draw itself and respond to mouse clicks
  6.  
  7. #ifdef PowerPlant_PCH
  8. #include PowerPlant_PCH
  9. #endif
  10.  
  11. #include "WellFreeCell.h"
  12. #include "CardDeck.h"
  13. #include "AcereApp.h"
  14. #include "CTextDoc.h"
  15. #include <LView.h>
  16. #include <LStream.h>
  17. #include <PP_Messages.h>
  18. #include <UDrawingState.h>
  19.  
  20. #include <Balloons.h>
  21.  
  22. extern CTextDoc *theDoc;
  23. extern    unsigned long     ourAvailRam;
  24.  
  25. // ---------------------------------------------------------------------------
  26. //        Ñ CreatePaneStream [static]
  27. // ---------------------------------------------------------------------------
  28. //    Return a new Pane object initialized using data from a Stream
  29.  
  30. WellFreeCell*
  31. WellFreeCell::CreateWellFreeCell(
  32.     LStream    *inStream)
  33. {
  34.     return (new WellFreeCell(inStream));
  35. }
  36.  
  37.  
  38. // ---------------------------------------------------------------------------
  39. //        Ñ WellFreeCell()
  40. // ---------------------------------------------------------------------------
  41. //    Default Constructor
  42.  
  43. WellFreeCell::WellFreeCell() : CardWell()
  44. {
  45.     InitCard();
  46.     
  47.     theWellHelp.hmmHelpType = khmmString;
  48.     CopyPString("\pMove any card here for temporary storage.", (StringPtr)theWellHelp.u.hmmString);
  49. }
  50.  
  51.  
  52. // ---------------------------------------------------------------------------
  53. //        Ñ WellFreeCell(const WellFreeCell&)
  54. // ---------------------------------------------------------------------------
  55. //    Copy Constructor
  56.  
  57. WellFreeCell::WellFreeCell(
  58.     const WellFreeCell    &inOriginal) : CardWell(inOriginal)
  59. {
  60.                                     // Copy members of Original
  61.     InitCard();
  62. }
  63.  
  64.  
  65. // ---------------------------------------------------------------------------
  66. //        Ñ WellFreeCell(SPaneInfo&)
  67. // ---------------------------------------------------------------------------
  68. //    Construct Pane from data in a struct
  69.  
  70. WellFreeCell::WellFreeCell(const SPaneInfo    &inPaneInfo) : CardWell(inPaneInfo)
  71. {
  72.     InitCard();
  73. }
  74.  
  75.  
  76. // ---------------------------------------------------------------------------
  77. //        Ñ WellFreeCell(LStream*)
  78. // ---------------------------------------------------------------------------
  79. //    Construct Pane from data in a Stream
  80.  
  81. WellFreeCell::WellFreeCell(
  82.     LStream    *inStream) : CardWell(inStream)
  83. {
  84. //    SPaneInfo    thePaneInfo;
  85. //    inStream->ReadData(&thePaneInfo, sizeof(SPaneInfo));
  86.     InitCard();
  87. }
  88.  
  89.  
  90. // ---------------------------------------------------------------------------
  91. //        Ñ InitPane
  92. // ---------------------------------------------------------------------------
  93. //    Initialize Pane from data in a struct
  94.  
  95. void
  96. WellFreeCell::InitCard(void)
  97. {
  98. //    CardWell::InitPane(inPaneInfo);
  99.     
  100.     theDoc->theFreeCells[theDoc->currentFreeCell] = this;
  101.     theDoc->currentFreeCell++;
  102. }
  103.  
  104.  
  105. // ---------------------------------------------------------------------------
  106. //        Ñ ~WellFreeCell
  107. // ---------------------------------------------------------------------------
  108. //    Destructor
  109.  
  110. WellFreeCell::~WellFreeCell()
  111. {
  112.     PutInside(nil);
  113.     
  114.     if (sLastPaneClicked == this) {
  115.         sLastPaneClicked = nil;
  116.     }
  117. }
  118.  
  119.  
  120. // ---------------------------------------------------------------------------
  121. //        Ñ Draw
  122. // ---------------------------------------------------------------------------
  123. //    Try to draw contents of a Pane
  124. //
  125. //    inSuperDrawRgnH specifies, in Port coordinates, the portion of the
  126. //    Pane's SuperView that needs to be drawn. Specify nil to bypass
  127. //    the intersection test.
  128. //    
  129. //    This is a wrapper function which calls DrawSelf if it is proper for
  130. //    the Pane to draw. This means that:
  131. //        > Pane's Visible property is on
  132. //        > Pane can be focused
  133. //        > Pane's Frame is in QuickDraw space
  134. //        > Pane's Frame intersects inSuperDrawRgnH
  135.  
  136. /*void    WellFreeCell::Draw(RgnHandle    inSuperDrawRgnH)
  137. {
  138.     Rect    frame;
  139.     if ( IsVisible()  &&
  140.          FocusDraw()  &&
  141.          CalcPortFrameRect(frame)  &&
  142.          ((inSuperDrawRgnH == nil) || RectInRgn(&frame, inSuperDrawRgnH)) )
  143.     {
  144.         if (itsCard == nil)
  145.         {
  146.             EraseRect(&frame);
  147.             FrameRoundRect(&frame, 20, 20);
  148.         }
  149.         else if (itsCard->card == kNoCard)
  150.         {
  151.             EraseRect(&frame);
  152.             FrameRoundRect(&frame, 20, 20);
  153.         }
  154.         else
  155.         {
  156.             theDeck->DrawCard(itsCard, frame, isHighlighted);
  157.             FrameRoundRect(&frame, 20, 20);
  158.         }
  159.     }
  160. }
  161. */
  162.  
  163. void WellFreeCell::AdjustCursor(Point inPortPt, const EventRecord &inMacEvent)
  164. {
  165.     OSErr    theErr;
  166.     Point    tempPoint;
  167.     
  168.     
  169.     inherited::AdjustCursor(inPortPt, inMacEvent);
  170.     if (theApp->balloonsActive)
  171.     {
  172.         LocalToGlobal(& topLeft(itsHelpRect));
  173.         LocalToGlobal(& botRight(itsHelpRect));
  174.         SetPt(&tempPoint, itsHelpRect.right -3, itsHelpRect.bottom -3);
  175.         theErr = HMShowBalloon(&theWellHelp, tempPoint, &itsHelpRect, nil, nil, 0, kHMRegularWindow);
  176.     }
  177.  
  178. }
  179.